package com.matrix.java.chap_05;

import java.util.Scanner;

/*
    显示每月第一天是星期几
 */
public class Ex5_28 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("年: ");
        int year = input.nextInt();
        System.out.print("星期: ");
        int weekday = input.nextInt();

        boolean isLeapYear = false;
        String dayOfWeek = "";
        String month = "";
        if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
            isLeapYear = true;
        }
        for (int i = 1; i <= 12; i++) {
            switch (i) {
                case 1:
                    month = "January";
                    break;
                case 2:
                    month = "February";
                    weekday += 3;
                    break;
                case 3:
                    month = "March";
                    if (isLeapYear) {
                        weekday += 1;
                    }
                    break;
                case 4:
                    month = "April";
                    weekday += 3;
                    break;
                case 5:
                    month = "May";
                    weekday += 2;
                    break;
                case 6:
                    month = "June";
                    weekday += 3;
                    break;
                case 7:
                    month = "July";
                    weekday += 2;
                    break;
                case 8:
                    month = "August";
                    weekday += 3;
                    break;
                case 9:
                    month = "September";
                    weekday += 3;
                    break;
                case 10:
                    month = "October";
                    weekday += 2;
                    break;
                case 11:
                    month = "November";
                    weekday += 3;
                    break;
                case 12:
                    month = "December";
                    weekday += 2;
                    break;
                default:
                    throw new IllegalStateException("Unexpected value: " + i);
            }
            if (weekday > 7) {
                weekday -= 7;
            }
            switch (weekday) {
                case 1:
                    dayOfWeek = "Monday";
                    break;
                case 2:
                    dayOfWeek = "Tuesday";
                    break;
                case 3:
                    dayOfWeek = "Wednesday";
                    break;
                case 4:
                    dayOfWeek = "Thursday";
                    break;
                case 5:
                    dayOfWeek = "Friday";
                    break;
                case 6:
                    dayOfWeek = "Saturday";
                    break;
                case 7:
                    dayOfWeek = "Sunday";
                    break;
            }
            System.out.println(month + " 1, " + year + " is " + dayOfWeek);
        }
        input.close();
    }
}
